home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1679 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: eua.ericsson.se!usenet
  2. From: euahjn@eua.ericsson.se (Henrik Johansson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Why use private class members instead of protected?
  5. Date: 12 Jan 1996 08:32:57 GMT
  6. Organization: Ericsson Telecom Systems Labs, Stockholm, Sweden
  7. Distribution: world
  8. Message-ID: <4d56bp$hr9@euas20.eua.ericsson.se>
  9. References: <30F4AB49.6ABB@sierra.net>
  10. Reply-To: euahjn@eua.ericsson.se
  11. NNTP-Posting-Host: euas31i2c37.eua.ericsson.se
  12. NNTP-Posting-User: euahjn
  13.  
  14. In article <30F4AB49.6ABB@sierra.net>, TGColwell <snowbull@sierra.net> writes:
  15. > I'm relatively new to c++.  I have one quick question:  If child 
  16. > classes can only access protected members of the parent class, 
  17. > why make any members of any class private?  Wouldn't it be 
  18. > better to make members of the parent class protected so that the 
  19. > class is alway "inheritance ready"?
  20. > Thanks in advance,
  21. > -Tyler
  22.  
  23. I think that the widely spread style to declare every data private and write
  24. access methods for each has some drawbacks. I would also like to see
  25. some code writers use `protected:' declarations. In fact, we here at our team
  26. at former ELLEmTEL company, famous for its C++ standards, have designed
  27. a team-wide houserule subset of the style guide, that *allows* protected variables.
  28. Base classes do become more `inheritance ready' in this manner. OTOH,
  29. if the base class is designed to have its `downside' inheritance interface
  30. publicly accessible to users of some reusable software framework `protected:'
  31. is not such a good idea.
  32.  
  33.  
  34.